<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>@yield('title')</title>
    <link rel="stylesheet" href="{{asset("static/css/element-ui.css")}}">
@yield('scriptLoad')
    <script src="{{asset("static/js/vue.js")}}"></script>
    <script src="{{asset("static/js/element-ui.js")}}"></script>
</head>
<body>
<div id="app">
    <el-row :gutter="24" justify="center" class="el-row--flex">
        <el-col :xs="24" :sm="24" :md="22" :lg="20" :xl="18" >
            <el-menu v-if="showMenu" :default-active="activeIndex" class="el-menu-demo" mode="horizontal">
                <el-menu-item index="user"><a href="{{ MODULE_URL  }}/user">用户管理</a></el-menu-item>
                <el-menu-item index="pay"><a href="{{ MODULE_URL  }}/pay">支付管理</a></el-menu-item>
            </el-menu>
            <div style="width: 100%;height: 1px;margin-bottom: 15px"></div>
            @yield('content')
        </el-col>
    </el-row>
</div>
</body>

<script src="{{asset("static/js/axios.min.js")}}"></script>
<script src="{{asset("static/js/qs.js")}}"></script>
<script>
    const request = axios.create({
        baseURI: "/",
        timeout: 5000
    });

    request.interceptors.request.use(request=> {
        request.transformRequest = [data => {
            return (typeof data === 'object' && !(data instanceof FormData)) ? Qs.stringify(data) : data
        }]
        request.headers['X-CSRF-TOKEN'] = document.querySelector('meta[name="csrf-token"]').content
        return request;
    })

    request.interceptors.response.use(response => {
        if (response.data.code !== undefined && response.data.code !== 0){
            new Vue().$message.error(response.data.message || "请求失败")
            return Promise.reject(response.data)
        }

        return response.data
    })
</script>
@yield('script')
@yield('style')
<style>
    a{
        text-decoration: none;
    }
</style>
</html>
